package com.wjjun.databinding;

import android.databinding.BindingAdapter;
import android.support.v7.widget.RecyclerView;

import com.wjjun.customview.R;
import com.yqritc.recyclerviewflexibledivider.FlexibleDividerDecoration;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

/**
 * recyclView
 * Created by 67535 on 2018/4/30.
 */
public class RecyclerViewAdapter {

    @BindingAdapter("viewDivider")
    public static void viewDivider(RecyclerView recyclerView, boolean showViewDivider) {
        if (showViewDivider) {
            FlexibleDividerDecoration dividerDecoration = new HorizontalDividerItemDecoration
                    .Builder(recyclerView.getContext())
                    .colorResId(R.color.divider_color)
                    .sizeResId(R.dimen.divider_height).build();

            recyclerView.addItemDecoration(dividerDecoration);

        }
    }
}
